/***************************************************************************
 *   Copyright (C) 2007 by Ziman & Xloverin                                *
 *   ziman@centrum.sk, xloverin@gmail.com                                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#include "prefsappearance.h"
#include <QFont>

void PrefsAppearance::setPrefs(PrefsAppearance::Prefs prefs)
{
	switch (prefs.tabPosition) {
		case QTabWidget::North: cbTabPosition->setCurrentIndex(0); break;
		case QTabWidget::South: cbTabPosition->setCurrentIndex(1); break;
		case QTabWidget::West: cbTabPosition->setCurrentIndex(2); break;
		case QTabWidget::East: cbTabPosition->setCurrentIndex(3); break;
	}

	QFont font;
	font.setFamily(prefs.termFontFace);
	cbFont->setCurrentFont(font);
	sbFontSize->setValue(prefs.termFontSize);
	cbTimestamps->setCheckState(prefs.showTimestamps ? Qt::Checked : Qt::Unchecked);
	cbShowTags->setCheckState(prefs.showTags ? Qt::Checked : Qt::Unchecked);
	leTimestamps->setText(prefs.timestampFormat);
}

PrefsAppearance::Prefs PrefsAppearance::prefs()
{
	Prefs prefs;

	static const QTabWidget::TabPosition tabPos[4] = {
		QTabWidget::North, QTabWidget::South,
  		QTabWidget::West, QTabWidget::East
	};
	prefs.tabPosition = tabPos[cbTabPosition->currentIndex()];

	prefs.termFontFace = cbFont->currentFont().family();
	prefs.termFontSize = sbFontSize->value();

	prefs.showTimestamps = (cbTimestamps->checkState() == Qt::Checked);
	prefs.timestampFormat = leTimestamps->text();
	
	prefs.showTags = (cbShowTags->checkState() == Qt::Checked);

	return prefs;
}

PrefsAppearance::PrefsAppearance ( QWidget* parent, Qt::WFlags fl )
		: QWidget ( parent, fl ), Ui::prefsAppearance()
{
	setupUi ( this );
}

PrefsAppearance::~PrefsAppearance()
{}

